﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;


namespace HostedRadioService
{
   // NOTE: In order to launch WCF Test Client for testing this service, please select RadioService.svc or RadioService.svc.cs at the Solution Explorer and start debugging.
   public class RadioService : IRadioService
   {

      #region Methods (2)

      // Private Methods (2) 

      //private Song[] MakeBlues()
      //{
      //   Song[] s = new Song[2];
      //   s[0] = new Song("Little Red Rooster", "Howlin Wolf", "Blues");
      //   s[1] = new Song("Stormy Monday", "T Bone Walker", "Blues");
      //   return s;
      //}

      //private Song[] MakeRock()
      //{
      //   Song[] s = new Song[2];
      //   s[0] = new Song("La Grange", "ZZ Top", "Rock");
      //   s[1] = new Song("Flirtin’ With Disaster", "Molly Hatchet", "Rock");
      //   return s;
      //}

      #endregion Methods

      #region IRadioService Members

      public Song[] GetSongsByGenre (string inGenre)
      {
         Song[] returnValue = null;
         RadioMusicEntities proxy = new RadioMusicEntities ();
         LkupGenre genre = proxy.LkupGenre.Where (_ => _.GenreName == inGenre).FirstOrDefault ();
         if (genre != null)
         {
            returnValue = proxy.Song.Where (s => s.GenreID == genre.GenreID).ToArray ();
         }
         return returnValue;

         //switch (inGenre.ToUpper())
         //{
         //   case "BLUES":
         //      return this.MakeBlues();
         //   case "ROCK":
         //      return this.MakeRock();
         //   default:
         //      return null;
         //}
      }




      public object GetAlbumsByGenre (string inGenre)
      {
         throw new NotImplementedException ();
      }

      #endregion
   }
}
   //[DataContract]
   //public class Song
   //{
   //   #region Fields (3)
   //   [DataMember]
   //   string Artist { get; set; }
   //   [DataMember]
   //   string Genre { get; set; }
   //   [DataMember]
   //   string Title { get; set; }


   //   #endregion Fields

   //   #region Constructors (1)

   //   public Song(string inTitle, string inArtist, string inGenre)
   //   {
   //      Title = inTitle;
   //      Artist = inArtist;
   //      Genre = inGenre;
   //   }

   //   #endregion Constructors
   //}

